home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3981 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  69 lines

  1. Path: news.cencom.net!ns!tanp
  2. From: tanp@ns (Bill Wendling)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: compiling- gcc v.s. cc
  5. Date: 1 Feb 1996 08:19:36 GMT
  6. Organization: Cen-Com Internet
  7. Distribution: world
  8. Message-ID: <4ept2o$jbs@news.cencom.net>
  9. References: <4emvi6$j4@cnn.Princeton.EDU>
  10. NNTP-Posting-Host: ns.cencom.net
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. CIT Information Centers inexplicably wrote:
  14.  
  15. } I am a mathematician and have written most of my C programs
  16. } for my own use. Unfortunately, I now need to make a program of mine
  17. } available to the world and have some questions.
  18.  
  19. } 1) Is the GNU C compiler (gcc) a standard compiler that most unix
  20. }    users have at their disposal?
  21.  
  22. This depends on what their sysop has put on the computer for them to use.
  23. gcc is available over the net to anyone free of charge.
  24.  
  25. }    The reason I'm asking is because I want to provide instructions 
  26. }    for compiling my program. I've been using gcc and it works fine.
  27.  
  28. You could make up a "make" file which will take care of the compilation
  29. without need for a lot of instruction.  
  30.  
  31. }    I experimented with cc but did did not get consistent results.
  32. }    On an SGI it compiled fine (both with gcc and cc), but not on 
  33. }    Sun-4 it only compiled with gcc and not with cc (cc produced
  34. }    a lot of error messages which seem to be connected to the
  35. }    way I declared my functions. I use prototype form as opposed
  36. }    to traditional form).
  37.  
  38. } this brings me to question...
  39.  
  40. } 2) Why would a program compile fine with cc on one machine but not on 
  41. }    another?
  42.  
  43. The C compiler may be older on the machine that gives you the errors
  44. and doesn't support prototyping.  You can get around this problem by
  45. making all prototypes conditionally "there" or not.  Here is an example
  46. of a .h file which you could use (from _Obfuscated C And Other Mysteries_,
  47. by Don Libes.  Copyright (C) 1993 by John Wiley & Sons, Inc.):
  48.  
  49. -------------------------------------------------------------------------
  50. #ifndef PROTO_H
  51. #define PROTO_H
  52. #if __STDC__ == 1 || PROTOTYPES_EXIST
  53. #define PROTO(A) A
  54. #else
  55. #define PROTO(A) ()
  56. #endif    /* has prototypes */
  57. #endif  /* PROTO_H */
  58. ------------------------------------------------------------------------
  59.  
  60. And then use it like:
  61.  
  62. int foofunc PROTO((int bar, char baz));
  63.  
  64.  
  65. --
  66. Bill Wendling         | "Pinky, are you thinking what I'm thinking?"
  67. tanp@ns.cencom.net  | "I think so, Brain, but burlap chafes me so."
  68. "Boom Shanka"       | Finger me for my Geek Code...NOW!
  69.